import request from "../utils/request";


// 新增书籍
export const addBookAPI = (data) => {
    return request({
        url: "/api/v1/novel/add/book",
        method: "post",
        data,
    });
};


// 查询书籍
export const getBookAPI = () => {
    return request({
        url: "/api/v1/novel/query/book/list",
        method: "get",
    });
};


//删除书籍
export const deleteBookAPI = (bookId) => {
    return request({
        url: `/api/v1/novel/delete/book/${bookId}`,
        method: "post",
    });
};


//生成书籍章节
export const addChapterAPI = (data) => {
    return request({
        url: `/api/v1/novel/gen/chapter/catalogs`,
        method: "post",
        data
    })
}


//新增书籍章节
export const addChapterContentAPI = (data) => {
    return request({
        url: `/api/v1/novel/add/chapter/catalogs`,
        method: "post",
        data
    })
}


//获取书籍所有章节目录
export const getChapterAPI = (bookId) => {
    return request({
        url: `/api/v1/novel/query/chapter/list`,
        method: "post",
        data: {
            bookId
        }
    })
}

// 生成章节基本事件
export const addChapterEventAPI = (data) => {
    return request({
        url: `/api/v1/novel/gen/chapter/event`,
        method: "post",
        data
    })
}


// 新增章节目录
export const addChapterCatalogAPI = (data) => {
    return request({
        url: `/api/v1/novel/add/chapter/events`,
        method: "post",
        data
    })
}


//查询章节事件
export const getChapterEventAPI = (bookId, chapterId) => {
    return request({
        url: `/api/v1/novel/query/chapter/events/${bookId}/${chapterId}`,
        method: "get",
        data: {
            chapterId
        }
    })
}


//修改章节事件
export const updateChapterEventAPI = (data) => {
    return request({
        url: `/api/v1/novel/update/chapter/events`,
        method: "post",
        data
    })
}


//生成内容
export const addBookContentAPI = (data) => {
    return request({
        url: `/api/v1/novel/gen/chapter/content/event`,
        method: "post",
        data
    })
}


// 获取章节内容
export const getChapterContentAPI = (bookId) => {
    return request({
        url: `/api/v1/novel/query/chapter/info`,
        method: "post",
        data: {
            chapterId: window.localStorage.getItem('chapterId'),
            bookId
        }
    })
}

// 修改章节名
export const updateChapterAPI = (data) => {
    return request({
        url: `/api/v1/novel/update/chapter`,
        method: "post",
        data
    })
}


//保存章节内容
export const saveChapterContentAPI = (data) => {
    return request({
        url: `/api/v1/novel/update/chapter`,
        method: "post",
        data
    })
}